package com.itbbs.redis.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * @Describe:[]
 * @title RedisProperties
 * @author liuyingao
 * @create 2021-05-30 17:38
 * @desc RedisProperties
 **/
@Component
@PropertySource("classpath:application-redis.properties")
public class RedisProperties {

    @Value("${writeHostAndProt}")
    private String writeHostAndProt;
    @Value("${readHostAndProt}")
    private String readHostAndProt;

    @Value("${commandTimeout}")
    private String commandTimeout; //int

    @Value("${maxIdle}")
    private String maxIdle;    //int

    @Value("${maxTotal}")
    private String maxTotal; //int

    @Value("${minIdle}")
    private String minIdle;    //int

    @Value("${maxWaitMillis}")
    private String maxWaitMillis;  //int

    @Value("${testOnBorrow}")
    private String testOnBorrow;

    @Value("${auth}")
    private String auth;

    public String getAuth() {
        return auth;
    }

    public void setAuth(String auth) {
        this.auth = auth;
    }

    public String getWriteHostAndProt() {
        return writeHostAndProt;
    }

    public void setWriteHostAndProt(String writeHostAndProt) {
        this.writeHostAndProt = writeHostAndProt;
    }

    public String getReadHostAndProt() {
        return readHostAndProt;
    }

    public void setReadHostAndProt(String readHostAndProt) {
        this.readHostAndProt = readHostAndProt;
    }

    public int getCommandTimeout() {
        int timenum = Integer.parseInt(commandTimeout);
        return timenum;
    }

    public void setCommandTimeout(String commandTimeout) {
        this.commandTimeout = commandTimeout;
    }

    public int getMaxIdle() {
        int maxIdleNum = Integer.parseInt(maxIdle);
        return maxIdleNum;
    }

    public void setMaxIdle(String maxIdle) {
        this.maxIdle = maxIdle;
    }

    public int getMaxTotal() {
        int maxTotalNum = Integer.parseInt(maxTotal);
        return maxTotalNum;
    }

    public void setMaxTotal(String maxTotal) {
        this.maxTotal = maxTotal;
    }

    public int getMinIdle() {
        int minIdleNum = Integer.parseInt(minIdle);
        return minIdleNum;
    }

    public void setMinIdle(String minIdle) {
        this.minIdle = minIdle;
    }

    public int getMaxWaitMillis() {
        int maxWaitMillisNum = Integer.parseInt(maxWaitMillis);
        return maxWaitMillisNum;
    }

    public void setMaxWaitMillis(String maxWaitMillis) {
        this.maxWaitMillis = maxWaitMillis;
    }

    public boolean isTestOnBorrow() {
        if (testOnBorrow.equals("true"))
        return true;
        return false;
    }

    public void setTestOnBorrow(boolean testOnBorrow) {
        if (testOnBorrow){
            this.testOnBorrow = "true";
        }
        if (!testOnBorrow){
            this.testOnBorrow = "false";
        }

    }


}
